// Copyright (c) 2012-2016 The Bitcoin Core developers
// Copyright (c) 2016-2019 The MagnaChain Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "transaction/bloom.h"

#include "coding/base58.h"
#include "misc/clientversion.h"
#include "key/key.h"
#include "transaction/merkleblock.h"
#include "misc/random.h"
#include "io/serialize.h"
#include "io/streams.h"
#include "coding/uint256.h"
#include "utils/util.h"
#include "utils/utilstrencodings.h"
#include "test/test_magnachain.h"

#include <vector>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(bloom_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
{
    MCBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);

    filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
    BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
    // One bit different in first byte
    BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter contains something it shouldn't!");

    filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
    BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")), "Bloom filter doesn't contain just-inserted object (2)!");

    filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
    BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")), "Bloom filter doesn't contain just-inserted object (3)!");

    MCDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
    stream << filter;

    std::vector<unsigned char> vch = ParseHex("03614e9b050000000000000001");
    std::vector<char> expected(vch.size());

    for (unsigned int i = 0; i < vch.size(); i++)
        expected[i] = (char)vch[i];

    BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());

    BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
    filter.clear();
    BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter should be empty!");
}

BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)
{
    // Same test as bloom_create_insert_serialize, but we add a nTweak of 100
    MCBloomFilter filter(3, 0.01, 2147483649UL, BLOOM_UPDATE_ALL);

    filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
    BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter doesn't contain just-inserted object!");
    // One bit different in first byte
    BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f0950c8")), "Bloom filter contains something it shouldn't!");

    filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
    BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")), "Bloom filter doesn't contain just-inserted object (2)!");

    filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
    BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")), "Bloom filter doesn't contain just-inserted object (3)!");

    MCDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
    stream << filter;

    std::vector<unsigned char> vch = ParseHex("03ce4299050000000100008001");
    std::vector<char> expected(vch.size());

    for (unsigned int i = 0; i < vch.size(); i++)
        expected[i] = (char)vch[i];

    BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());
}

BOOST_AUTO_TEST_CASE(bloom_create_insert_key)
{
    std::string strSecret = std::string("5Kg1gnAjaLfKiwhhPpGS3QfRg2m6awQvaj98JCZBZQ5SuS2F15C");
    MagnaChainSecret vchSecret;
    BOOST_CHECK(vchSecret.SetString(strSecret));

    MCKey key = vchSecret.GetKey();
    MCPubKey pubkey = key.GetPubKey();
    std::vector<unsigned char> vchPubKey(pubkey.begin(), pubkey.end());

    MCBloomFilter filter(2, 0.001, 0, BLOOM_UPDATE_ALL);
    filter.insert(vchPubKey);
    uint160 hash = pubkey.GetID();
    filter.insert(std::vector<unsigned char>(hash.begin(), hash.end()));

    MCDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
    stream << filter;

    std::vector<unsigned char> vch = ParseHex("038fc16b080000000000000001");
    std::vector<char> expected(vch.size());

    for (unsigned int i = 0; i < vch.size(); i++)
        expected[i] = (char)vch[i];

    BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());
}

BOOST_AUTO_TEST_CASE(bloom_match)
{
    // Random real transaction (b4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b)
    MCDataStream stream(ParseHex("01000000010b26e9b7735eb6aabdf358bab62f9816a21ba9ebdb719d5299e88607d722c190000000008b4830450220070aca44506c5cef3a16ed519d7c3c39f8aab192c4e1c90d065f37b8a4af6141022100a8e160b856c2d43d27d8fba71e5aef6405b8643ac4cb7cb3c462aced7f14711a0141046d11fee51b0e60666d5049a9101a72741df480b96ee26488a4d3466b95c9a40ac5eeef87e10a5cd336c19a84565f80fa6c547957b7700ff4dfbdefe76036c339ffffffff021bff3d11000000001976a91404943fdd508053c75000106d3bc6e2754dbcff1988ac2f15de00000000001976a914a266436d2965547608b9e15d9032a7b9d64fa43188ac00000000"), SER_DISK, CLIENT_VERSION);
    MCTransaction tx(deserialize, stream);

    // and one which spends it (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff832b110436)
    unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x85, 0x65, 0xef, 0x40, 0x6d, 0xd5, 0xd6, 0x3d, 0x4f, 0xf9, 0x4f, 0x31, 0x8f, 0xe8, 0x20, 0x27, 0xfd, 0x4d, 0xc4, 0x51, 0xb0, 0x44, 0x74, 0x01, 0x9f, 0x74, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x49, 0x30, 0x46, 0x02, 0x21, 0x00, 0xda, 0x0d, 0xc6, 0xae, 0xce, 0xfe, 0x1e, 0x06, 0xef, 0xdf, 0x05, 0x77, 0x37, 0x57, 0xde, 0xb1, 0x68, 0x82, 0x09, 0x30, 0xe3, 0xb0, 0xd0, 0x3f, 0x46, 0xf5, 0xfc, 0xf1, 0x50, 0xbf, 0x99, 0x0c, 0x02, 0x21, 0x00, 0xd2, 0x5b, 0x5c, 0x87, 0x04, 0x00, 0x76, 0xe4, 0xf2, 0x53, 0xf8, 0x26, 0x2e, 0x76, 0x3e, 0x2d, 0xd5, 0x1e, 0x7f, 0xf0, 0xbe, 0x15, 0x77, 0x27, 0xc4, 0xbc, 0x42, 0x80, 0x7f, 0x17, 0xbd, 0x39, 0x01, 0x41, 0x04, 0xe6, 0xc2, 0x6e, 0xf6, 0x7d, 0xc6, 0x10, 0xd2, 0xcd, 0x19, 0x24, 0x84, 0x78, 0x9a, 0x6c, 0xf9, 0xae, 0xa9, 0x93, 0x0b, 0x94, 0x4b, 0x7e, 0x2d, 0xb5, 0x34, 0x2b, 0x9d, 0x9e, 0x5b, 0x9f, 0xf7, 0x9a, 0xff, 0x9a, 0x2e, 0xe1, 0x97, 0x8d, 0xd7, 0xfd, 0x01, 0xdf, 0xc5, 0x22, 0xee, 0x02, 0x28, 0x3d, 0x3b, 0x06, 0xa9, 0xd0, 0x3a, 0xcf, 0x80, 0x96, 0x96, 0x8d, 0x7d, 0xbb, 0x0f, 0x91, 0x78, 0xff, 0xff, 0xff, 0xff, 0x02, 0x8b, 0xa7, 0x94, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xba, 0xde, 0xec, 0xfd, 0xef, 0x05, 0x07, 0x24, 0x7f, 0xc8, 0xf7, 0x42, 0x41, 0xd7, 0x3b, 0xc0, 0x39, 0x97, 0x2d, 0x7b, 0x88, 0xac, 0x40, 0x94, 0xa8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xc1, 0x09, 0x32, 0x48, 0x3f, 0xec, 0x93, 0xed, 0x51, 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00};
    std::vector<unsigned char> vch(ch, ch + sizeof(ch) -1);
    MCDataStream spendStream(vch, SER_DISK, CLIENT_VERSION);
    MCTransaction spendingTx(deserialize, spendStream);

    MCBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    filter.insert(uint256S("0xb4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b"));
    BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match tx hash");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    // byte-reversed tx hash
    filter.insert(ParseHex("6bff7fcd4f8565ef406dd5d63d4ff94f318fe82027fd4dc451b04474019f74b4"));
    BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match manually serialized tx hash");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    filter.insert(ParseHex("30450220070aca44506c5cef3a16ed519d7c3c39f8aab192c4e1c90d065f37b8a4af6141022100a8e160b856c2d43d27d8fba71e5aef6405b8643ac4cb7cb3c462aced7f14711a01"));
    BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match input signature");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    filter.insert(ParseHex("046d11fee51b0e60666d5049a9101a72741df480b96ee26488a4d3466b95c9a40ac5eeef87e10a5cd336c19a84565f80fa6c547957b7700ff4dfbdefe76036c339"));
    BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match input pub key");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    filter.insert(ParseHex("04943fdd508053c75000106d3bc6e2754dbcff19"));
    BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match output address");
    BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(spendingTx), "Simple Bloom filter didn't add output");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    filter.insert(ParseHex("a266436d2965547608b9e15d9032a7b9d64fa431"));
    BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match output address");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    filter.insert(MCOutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bdaab65e73b7e9260b"), 0));
    BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match MCOutPoint");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    MCOutPoint prevOutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bdaab65e73b7e9260b"), 0);
    {
        std::vector<unsigned char> data(32 + sizeof(unsigned int));
        memcpy(&data[0], prevOutPoint.hash.begin(), 32);
        memcpy(&data[32], &prevOutPoint.n, sizeof(unsigned int));
        filter.insert(data);
    }
    BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match manually serialized MCOutPoint");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    filter.insert(uint256S("00000009e784f32f62ef849763d4f45b98e07ba658647343b915ff832b110436"));
    BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched random tx hash");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    filter.insert(ParseHex("0000006d2965547608b9e15d9032a7b9d64fa431"));
    BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched random address");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    filter.insert(MCOutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bdaab65e73b7e9260b"), 1));
    BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched MCOutPoint for an output we didn't care about");

    filter = MCBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    filter.insert(MCOutPoint(uint256S("0x000000d70786e899529d71dbeba91ba216982fb6ba58f3bdaab65e73b7e9260b"), 0));
    BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched MCOutPoint for an output we didn't care about");
}

BOOST_AUTO_TEST_CASE(merkle_block_1)
{
    // Random real block (0000000000013b8ab2cd513b0261a14096412195a72a0c4827d229dcc7e0f7af)
    // With 9 txes
    MCBlock block;
    std::string str1("000000205243eb2930bf36d12c49432a33d8010e3c16d32599a4e7bc8d94f8b0378baba1f9f71ac26f583195210b99f6390a770fa478684433d5e9f2f6b65c3aab78f2f30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000071d4205cb6a90d20000000000000000000000000000000000000000000000000000000000000000000000000ffffffff000902000000010000000000000000000000000000000000000000000000000000000000000000ffffffff6d5900483045022100a07ba11d8b573871016dbe4a4d1b39efde805db591a32b66f1f5b590f28567680220686f089201ebf6d1dedbeac60f99103c1db5e5e2413678a69ff0736c7909b7870121020673eeb98949f2163091c1737f66585cff0a396238309cc6c1ecc1bce4eb73eafffffffffd05010010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac");
    std::string str2("0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0010a5d4e80000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac00f472dfea0000001976a914cd3c213a25931ab82665dd6e7a956a71d5d389de88ac0000000000000000266a24aa21a9ed36142c3f52be368680de7b70a8b038a7e6dc707af7656d2cd3e1b32e0ca6e43e000000000200000001169a6fa936256c77d7a6f26045e1fbd5ab3cc06809fb116c1be35f5be7e6a7bf000000006a47304402207fb6f54907af77e22779a0c968fd644caa6ee7e740b1b3db962e55e34791229f02201747e387cb5bd99e8f48146a3c23115ecaa129bda45da2422c048f6b0899e68d01210226dcde3a6fc22bee545476b63a968a81ac28de5142d09e3af5bc2255c7f24ba5feffffff0200e1f505000000001976a9147a00440d5a772d57a505c94dd6cd083d88ac07e988ac40c2aec4e80000001976a91422a3636d644cb2bd47d28f630ba3882a6a9f320288ac08000000020000000114fcb263bfe62b17411f9c9f66879d6e949bab372089ad65765d33adb86ef723120000006a47304402206231f20c6ab932187193f4d179a18ccc03b51f724d09b5191c57b7226c9a6fa602203146340c2858667fd3d08aeca09bb56ba446220b1b6b3cdd4bfebef37c1f66060121020d49c1b0f56e28fb1bb6bec232e4e6bb811742ef880528693cd70b9e55fb8fcffeffffff0220e9a9cce80000001976a91492780f4ae29ae6d49c14a6ba4d1c68e4f0b566fd88ac00e1f505000000001976a91484967ec70dfefb29ae1256d57dbeefa68aef916688ac08000000020000000114fcb263bfe62b17411f9c9f66879d6e949bab372089ad65765d33adb86ef723d40000006b48304502210084372614eb3d7833a2fa2a22bbc4664f333a0799b6fbc81e4566c44da53d543b022045d71ace5f209d9c648782eddff9bb63b587adfc2bde0e625dca6898fd24565d0121020d49c1b0f56e28fb1bb6bec232e4e6bb811742ef880528693cd70b9e55fb8fcffeffffff0220e9a9cce80000001976a914d440eb33de598245fd1c0aab3396d1b98a3cbb3f88ac00e1f505000000001976a91484967ec70dfefb29ae1256d57dbeefa68aef916688ac0800000002000000019b0bfc4ce898b2694a26b0c31a7b5d442c524c7e7e302ea6400c84793f91aaa4010000006a473044022053887354469753cd0b9b44c1505c3f83628d0bcf5a8bd9559ee24ad97c166571022030bd932b09e6212b6999b982a4897560859fbbac79529fa789d0701f7124aa7a0121020f61c0e10db4282061e2427bff4d803909532cd7b6ecb719128d427e42261565feffffff0200e1f505000000001976a9147a00440d5a772d57a505c94dd6cd083d88ac07e988ac40c2aec4e80000001976a914ac31e6d1c6144ff949d3cbd100341adb253c5f3888ac080000000200000001bd25de8cb31bb483b585cdab9449edefa203c1bfeac89996de2ae1f2d9ff5806000000006b48304502210094e51a57b69f9de092d97667763f7228cd29e52725ee3483d1443d50db7a21b902201185430f3dcbec7e973a4ae5ba2dc02b73a4b19241c5123d877cfa91d273aab001210344a59b922272da796c1a0f5353f84bcc7713ff83190506c0c6ad5a8b6fa1f7c7feffffff0240c2aec4e80000001976a914b9e960a3c257f54361800607cbd43fcafc21e65588ac00e1f505000000001976a914cd427c7443af380b62d132541576da7b8816a0c588ac080000000200000001672e24e17913671926765e58ffb71d83a1cc509dd951a38758c41d07ab75d282000000006b483045022100f3ed5e961dcd7e7e67590e8a716618fe741a1ab6c18cda8afbf407164603b2d00220072561c48e52f915949aebfd218d61b91d203fc510a7e88a061ccc35049316ce01210270ec9b8e382246be8efab73d315befcffb99794289e0b2d67a75ff79b8da44e8feffffff0240c2aec4e80000001976a914ee1f2d3becb8cd9b1b65dd03b763ef31374aa94f88ac00e1f505000000001976a91484967ec70dfefb29ae1256d57dbeefa68aef916688ac08000000020000000162d5c91aa732fb01e884348b27693cc52f559e1042bbe26ede27dbfb3cbd791a010000006b483045022100a2ec0a7cccfc719cedef30fb16468a62e0d3c5ec1f27a05fa29ad0e6e87401f7022068b3f5cd85e9dfa4fb125a0fb9c206b07b25991c7cc9b7ded840652efe27cbc3012103d2200335bbb2295d01d1b7ac64ba2af106fcc37c43b23ac06190a3dfbfea02f6feffffff0200e1f505000000001976a9141954a67c26a51d7e36631f8016ad282ec7aa970588ac40c2aec4e80000001976a9145fe7b847dcda4c5115f6c8f97d89628bbc8229bd88ac08000000020000000137422c41bab66db269786849e28849dc1c4d9b197a8ab53e6ade050e643d0263010000006b483045022100ad72099be0011f02a0aec9ee1c5bb8c1e110eb06b34beadb19a4ed658680535402200b0f655afe1cc3561cba90ab3dd5efb8020c3a59cefe43781c7d5c2c50b4511a012103305c5a3a88b4f73827e1125e7dfca742c9b53a6051895591581190b751fd22c6feffffff0240c2aec4e80000001976a9141b59eea78b164743a3acb9c165d8e5aa95b2155188ac00e1f505000000001976a9147a00440d5a772d57a505c94dd6cd083d88ac07e988ac08000000080100010002000100010001000100010000");
    std::string str = str1 + str2;
    MCDataStream stream(ParseHex(str.c_str()), SER_NETWORK, PROTOCOL_VERSION);
    stream >> block;

    MCBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    // Match the last transaction
    filter.insert(uint256S("0xbb2e5b9a76bb78bf32465e2a37f0453bd40dc2ba56d9851c84282ecd068d01a9"));

    MCMerkleBlock merkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
    std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];

    BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xbb2e5b9a76bb78bf32465e2a37f0453bd40dc2ba56d9851c84282ecd068d01a9"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 8);

    std::vector<uint256> vMatched;
    std::vector<unsigned int> vIndex;
    BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot);
    BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
    for (unsigned int i = 0; i < vMatched.size(); i++)
        BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);

    // Also match the 8th transaction
    filter.insert(uint256S("0xf5f7ccc7daab8650dd18b4a5843d03d009c0da6fba9cc0c22b6f1b729ccff678"));
    merkleBlock = MCMerkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 2);

    BOOST_CHECK(merkleBlock.vMatchedTxn[1] == pair);

    BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xf5f7ccc7daab8650dd18b4a5843d03d009c0da6fba9cc0c22b6f1b729ccff678"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 7);

    BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot);
    BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
    for (unsigned int i = 0; i < vMatched.size(); i++)
        BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
}

BOOST_AUTO_TEST_CASE(merkle_block_2)
{
    // Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34ae6)
    // With 4 txes
    MCBlock block;
    std::string str1 = "03000030d91c71aa207963d6a82f6129899f590a5f24dd3dfc4440ab44e19c2a3c60d707b471d09d7f56806e04badf48571e6ee72502256de3ccb03d610a0873173430dd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006da7215c6ec10f20000000000000000000000000000000000000000000000000000000000000000000000000ffffffff000402000000010000000000000000000000000000000000000000000000000000000000000000ffffffff6c5d004730440220170f488216711a215077f73cb8501e50b547630190d9c8a758d3f0e46295742402203a084ab9dd975e19df53f05e606d230e047e451d3bba3df669c602fc0b266a91012102180cba80b4725b6cde1b251ce059e7d32c4477a717532c2034eb748931fd1f4bfffffffffd05010010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5";
    std::string str2 = "d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988aca09658d5ea0000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0000000000000000266a24aa21a9ed50d8cb1ea9940183aa28dc9afc2140d47e25dedba58abc7fcf36763f65571ffc000000000200000001df68e50dd2cb7c9b9e195f70ae7925ce6a29fe5b317c7668c81f9650abbf479b010000006a473044022054349965336ed08b39b46a5247e1c4bc34e2eaba608616a34d75df78b4b79b2d02202c467d446e13da87d6dee4870157d9d8b8bb1e6b247ae715eb0d5822c32a2cae012102bf55faf26b5d58f994f2aa2fadf58ae930f797c5ec86e1a1ed62ce85bd39c01dfeffffff02c06bd303e80000001976a914abe5816aa3c62de61b30019e59b60b02c0ec494d88ac00ca9a3b000000001976a914b06b9f3ff7ff7644cef0c207eb92886d1ffcd1cf88ac0c00000002000000018711b5bacb4d1c72e6c11702e1a8fd52b573670e3261ba275053f29409123a20010000006a47304402206a28e676e644d3b8d4100c2061776cd4b8a8f35e51d3cac72de02b141f50bad602201afa5a96f6abb0e925f286f8d056a3eb7e8fbfbe5acbed0c6ce3fa258bb615ba0121024a7afabcb9d516dde3f47ea77665d423d75231ee288406c675a50fd4d49af743feffffff028074b8b4e80000001976a914f63179de47a99edbf8155ede2cbddc1141d864d188ac00e1f505000000001976a914df7b0d4b9c00a6e2f2442cf6dde95942a2acbaa388ac0c0000000200000001ea873dfe3d84c22de7d36cfe29b230d4ee3c61a816fe7817475b29f07ce02295000000006b4830450221008f6df8f510e765f93a2fb6acf7beadc0316e352cee63841a92d18d9ed56a5c2f02207ba55cdec9931d006ce9016aba8ed0b0ae1c64780a46110272e336b10ce18f6f0121026810d7dc92dd57b7b81d3e97667695facb80d0654573d4eeb75c55d15d3433a4feffffff028074b8b4e80000001976a914e6b92a052efdc25282448d6f56e9379762cb65fd88ac00e1f505000000001976a914b06b9f3ff7ff7644cef0c207eb92886d1ffcd1cf88ac0c00000004010001000100010000";
    std::string str = str1 + str2;
    MCDataStream stream(ParseHex(str.c_str()), SER_NETWORK, PROTOCOL_VERSION);
    stream >> block;

    MCBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    // Match the first transaction
    filter.insert(uint256S("ce5e9389ae02c9806c0ef35baac12b518ba08736f5c04b28bc5c41bec4440e8a"));

    MCMerkleBlock merkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
    std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];

    BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("ce5e9389ae02c9806c0ef35baac12b518ba08736f5c04b28bc5c41bec4440e8a"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0);

    std::vector<uint256> vMatched;
    std::vector<unsigned int> vIndex;
    BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot);
    BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
    for (unsigned int i = 0; i < vMatched.size(); i++)
        BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);

    // Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T3QvUKBz4qXMRpkg8jsfB5)
    // This should match the third transaction because it spends the output matched
    // It also matches the fourth transaction, which spends to the pubkey again

    filter.insert(ParseHex("b06b9f3ff7ff7644cef0c207eb92886d1ffcd1cf"));
    //be modify: the third did not spends 2nd output
    filter.insert(ParseHex("024a7afabcb9d516dde3f47ea77665d423d75231ee288406c675a50fd4d49af743"));// 3 vin pubkey

    merkleBlock = MCMerkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 4);

    BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]);

    BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("08f288ad168186243b6fa7c61e4e77ac01211d3304e9c72215de5066edb40a45"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1);

    BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("42fd6e1df64211bb59ac1aa2fd2ded14a7a80f6dd5b9dc391633121fe596d657"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 2);

    BOOST_CHECK(merkleBlock.vMatchedTxn[3].second == uint256S("44aa5f8523be38ff8c42ab448bf586c389d7ca9f07382201d8d7eb2c774d49f3"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[3].first == 3);

    BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot);
    BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
    for (unsigned int i = 0; i < vMatched.size(); i++)
        BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
}

BOOST_AUTO_TEST_CASE(merkle_block_2_with_update_none)
{
    // Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34ae6)
    // With 4 txes
    MCBlock block;
    std::string str1 = "03000030d91c71aa207963d6a82f6129899f590a5f24dd3dfc4440ab44e19c2a3c60d707b471d09d7f56806e04badf48571e6ee72502256de3ccb03d610a0873173430dd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006da7215c6ec10f20000000000000000000000000000000000000000000000000000000000000000000000000ffffffff000402000000010000000000000000000000000000000000000000000000000000000000000000ffffffff6c5d004730440220170f488216711a215077f73cb8501e50b547630190d9c8a758d3f0e46295742402203a084ab9dd975e19df53f05e606d230e047e451d3bba3df669c602fc0b266a91012102180cba80b4725b6cde1b251ce059e7d32c4477a717532c2034eb748931fd1f4bfffffffffd05010010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5";
    std::string str2 = "d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0010a5d4e80000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988aca09658d5ea0000001976a9143b7a6ab9392353d4c6c8b8907e855cb88b2fae7988ac0000000000000000266a24aa21a9ed50d8cb1ea9940183aa28dc9afc2140d47e25dedba58abc7fcf36763f65571ffc000000000200000001df68e50dd2cb7c9b9e195f70ae7925ce6a29fe5b317c7668c81f9650abbf479b010000006a473044022054349965336ed08b39b46a5247e1c4bc34e2eaba608616a34d75df78b4b79b2d02202c467d446e13da87d6dee4870157d9d8b8bb1e6b247ae715eb0d5822c32a2cae012102bf55faf26b5d58f994f2aa2fadf58ae930f797c5ec86e1a1ed62ce85bd39c01dfeffffff02c06bd303e80000001976a914abe5816aa3c62de61b30019e59b60b02c0ec494d88ac00ca9a3b000000001976a914b06b9f3ff7ff7644cef0c207eb92886d1ffcd1cf88ac0c00000002000000018711b5bacb4d1c72e6c11702e1a8fd52b573670e3261ba275053f29409123a20010000006a47304402206a28e676e644d3b8d4100c2061776cd4b8a8f35e51d3cac72de02b141f50bad602201afa5a96f6abb0e925f286f8d056a3eb7e8fbfbe5acbed0c6ce3fa258bb615ba0121024a7afabcb9d516dde3f47ea77665d423d75231ee288406c675a50fd4d49af743feffffff028074b8b4e80000001976a914f63179de47a99edbf8155ede2cbddc1141d864d188ac00e1f505000000001976a914df7b0d4b9c00a6e2f2442cf6dde95942a2acbaa388ac0c0000000200000001ea873dfe3d84c22de7d36cfe29b230d4ee3c61a816fe7817475b29f07ce02295000000006b4830450221008f6df8f510e765f93a2fb6acf7beadc0316e352cee63841a92d18d9ed56a5c2f02207ba55cdec9931d006ce9016aba8ed0b0ae1c64780a46110272e336b10ce18f6f0121026810d7dc92dd57b7b81d3e97667695facb80d0654573d4eeb75c55d15d3433a4feffffff028074b8b4e80000001976a914e6b92a052efdc25282448d6f56e9379762cb65fd88ac00e1f505000000001976a914b06b9f3ff7ff7644cef0c207eb92886d1ffcd1cf88ac0c00000004010001000100010000";
    std::string str = str1 + str2;
    MCDataStream stream(ParseHex(str.c_str()), SER_NETWORK, PROTOCOL_VERSION);
    stream >> block;

    MCBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE);
    // Match the first transaction
    filter.insert(uint256S("ce5e9389ae02c9806c0ef35baac12b518ba08736f5c04b28bc5c41bec4440e8a"));

    MCMerkleBlock merkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
    std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];

    BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("ce5e9389ae02c9806c0ef35baac12b518ba08736f5c04b28bc5c41bec4440e8a"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0);

    std::vector<uint256> vMatched;
    std::vector<unsigned int> vIndex;
    BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot);
    BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
    for (unsigned int i = 0; i < vMatched.size(); i++)
        BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);

    // Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T3QvUKBz4qXMRpkg8jsfB5)
    // This should not match the third transaction though it spends the output matched
    // It will match the fourth transaction, which has another pay-to-pubkey output to the same address
    filter.insert(ParseHex("b06b9f3ff7ff7644cef0c207eb92886d1ffcd1cf"));

    merkleBlock = MCMerkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 3);

    BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]);

    BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("08f288ad168186243b6fa7c61e4e77ac01211d3304e9c72215de5066edb40a45"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1);

    BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("44aa5f8523be38ff8c42ab448bf586c389d7ca9f07382201d8d7eb2c774d49f3"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 3);

    BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot);
    BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
    for (unsigned int i = 0; i < vMatched.size(); i++)
        BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
}

BOOST_AUTO_TEST_CASE(merkle_block_3_and_serialize)
{
    // Random real block (000000000000dab0130bbcc991d3d7ae6b81aa6f50a798888dfe62337458dc45)
    // With one tx
    MCBlock block;
    std::string str1 = "030000303f6cca9688f41f877d48de8dc8606137288a5dba4b6b14612ac831648edf6372422a3bfdceea595e60ea35d593ad0ebf9b4c63293c1447e564259ceacc3541400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042d1215c8db20620000000000000000000000000000000000000000000000000000000000000000000000000ffffffff000102000000010000000000000000000000000000000000000000000000000000000000000000ffffffff6d5e00483045022100f80105c103318a4164adabb71a19ae44c1383326b84f6b96e942abd8f9e3cbc502206694ffef9f81c4602d9a548b3d549aa13ffc0ad6a1df4ec966a3ded949a7ac8d012102f73fbe797a58dc0ef25f4b3b4ab2f3b86fafb6408cb86c426854e22bc04fe335fffffffffd05010010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac";
    std::string str2 = "0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0010a5d4e80000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac00c548cfea0000001976a914b7625dd28865ca9d4c3644bae252b9773b9ddc4388ac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90000000001010000";
    std::string str = str1 + str2;
    MCDataStream stream(ParseHex(str.c_str()), SER_NETWORK, PROTOCOL_VERSION);
    stream >> block;

    MCBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    // Match the only transaction
    filter.insert(uint256S("404135ccea9c2564e547143c29634c9bbf0ead93d535ea605e59eacefd3b2a42"));

    MCMerkleBlock merkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);

    BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("404135ccea9c2564e547143c29634c9bbf0ead93d535ea605e59eacefd3b2a42"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0);

    std::vector<uint256> vMatched;
    std::vector<unsigned int> vIndex;
    BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot);
    BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
    for (unsigned int i = 0; i < vMatched.size(); i++)
        BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);

    MCDataStream merkleStream(SER_NETWORK, PROTOCOL_VERSION);
    merkleStream << merkleBlock;
    std::string strmks = HexStr(merkleStream.begin(), merkleStream.end());

    std::vector<unsigned char> vch = ParseHex("030000303f6cca9688f41f877d48de8dc8606137288a5dba4b6b14612ac831648edf6372422a3bfdceea595e60ea35d593ad0ebf9b4c63293c1447e564259ceacc3541400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042d1215c8db20620000000000000000000000000000000000000000000000000000000000000000000000000ffffffff000100000001422a3bfdceea595e60ea35d593ad0ebf9b4c63293c1447e564259ceacc3541400101");
    std::vector<char> expected(vch.size());

    for (unsigned int i = 0; i < vch.size(); i++)
        expected[i] = (char)vch[i];

    BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), merkleStream.begin(), merkleStream.end());
}

BOOST_AUTO_TEST_CASE(merkle_block_4)
{
    // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6dea4)
    // With 7 txes
    MCBlock block;
    std::string str1 = "0000002040c8871a93779e099932c2dba1f6e75320159699a376b87472d86ab37a3324657564905c0104943684ccd7dc0c79de84d8fc4efd791dd49e2f4e17a385a459b700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f94f205c17460620000000000000000000000000000000000000000000000000000000000000000000000000ffffffff000702000000010000000000000000000000000000000000000000000000000000000000000000ffffffff6c580047304402203c9721b3dfe248ba22dbd817d3310233880ce16a44663fcf643782a7cb70b48702205e40ce6aa55439f4df780e0ac2aceea200dcb42613d8e0d96ac6e41ac5dd8c08012103fd776a5ed7b9556b9288afcfe9e97165d61857f210e8fced152f7f4fc4be0389fffffffffd05010010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e800000019";
    std::string str2 = "76a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac406868dbea0000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0000000000000000266a24aa21a9edd81e5fe7e143c954e1262b36e87dbc95ab75d3e6329dde611ffd763cfa258224000000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f45286a0000006a473044022014ff3e7c079cd5a99dfa2a7293bb529db0e84b96127ac53f6f7a719310ec258d02203468a9696b8422b947c71b9e75767487bdf4b77ef7a2584b5c1a7d7920a79501012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0220e9a9cce80000001976a914c76ef9c3c2b5b91ea0b5c1e56142f8d3363d4b6988ac00e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac070000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f4528590000006a47304402200adcd3e60872f407d5e502ca47016a2a14670bf8591485aa63257ae78c3d96d602204a830654e89785a1b003f57edfcba4b8c9630f697546279fec374a4c94a00cd2012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0200e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac20e9a9cce80000001976a91469a9ed5a2b7816439e81f5276c8fa31a5f5a17ba88ac070000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f4528240000006b483045022100b6d34ad0dd99edb2ff423df2b39fb8b7d8bb24cacb9a0ce9db43b1847ab6a0bb0220485540de7f90783ad11eca498f07640199c5a98b229571158a31b001a8437e73012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0200e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac20e9a9cce80000001976a9143d7831d6b59e5a7dba3a65b51154a3e2e4a866a088ac070000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f4528980000006b483045022100eec9b36cd4f5f9cf9354fa0802189bfd599524bc98478bef86f02e18194479cf0220090ac2f839fb2d889f2940b81a5574306a685c6df755f59298294918547edc04012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0200e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac20e9a9cce80000001976a914f405bfd6cd37be47289f1f9ca2e46b29be00af9588ac07000000020000000188d6cc289c0b578c075b29d8dcf0dd663618b66f5d9dc790d4e3b5afb26e6af7a60000006a47304402205f3fa38ff5d610c68ff5c957b6f5b048aae10edcd522b8e4127bfae835408761022071d359cfc293121d8a6ad112c74f895521b1654af9a4f25d133e693de5977c1b01210231f8f403c7a634ac42d6282903edc51cf6ccc32d34e9201c2b9e489c88b495fcfeffffff0220e9a9cce80000001976a9144d6643521444b1efb13cc8b07be9740f45f53d6488ac00e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac07000000020000000188d6cc289c0b578c075b29d8dcf0dd663618b66f5d9dc790d4e3b5afb26e6af7930000006b483045022100ae538d0225ccd95b5eb616deffdde10b4b9ad495075e796775c0d9272cd00bb4022021c804aa60ea1c45d2cab46cf55851e124ef2b218091509f547e63a46577fb7a01210231f8f403c7a634ac42d6282903edc51cf6ccc32d34e9201c2b9e489c88b495fcfeffffff0220e9a9cce80000001976a91496fdd3e3dd5643663dc65be9d4bcdb263002b85288ac00e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac070000000301000400020000";
    std::string strBlock = str1 + str2;
    MCDataStream stream(ParseHex(strBlock.c_str()), SER_NETWORK, PROTOCOL_VERSION);
    stream >> block;
    
    std::string stdblockid = block.GetHash().ToString();

    MCBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
    // Match the last transaction
    filter.insert(uint256S("82d275ab071dc45887a351d99d50cca1831db7ff585e762619671379e1242e67"));

    MCMerkleBlock merkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
    std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];

    BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("82d275ab071dc45887a351d99d50cca1831db7ff585e762619671379e1242e67"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 6);

    std::vector<uint256> vMatched;
    std::vector<unsigned int> vIndex;
    BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot);
    BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
    for (unsigned int i = 0; i < vMatched.size(); i++)
        BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);

    // Also match the 4th transaction
    filter.insert(uint256S("1a79bd3cfbdb27de6ee2bb42109e552fc53c69278b3484e801fb32a71ac9d562"));
    merkleBlock = MCMerkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 2);

    BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("1a79bd3cfbdb27de6ee2bb42109e552fc53c69278b3484e801fb32a71ac9d562"));
    BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 3);

    BOOST_CHECK(merkleBlock.vMatchedTxn[1] == pair);

    BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot);
    BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
    for (unsigned int i = 0; i < vMatched.size(); i++)
        BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
}

BOOST_AUTO_TEST_CASE(merkle_block_4_test_p2pubkey_only)
{
    // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6dea4)
    // With 7 txes
    MCBlock block;
    std::string str1 = "0000002040c8871a93779e099932c2dba1f6e75320159699a376b87472d86ab37a3324657564905c0104943684ccd7dc0c79de84d8fc4efd791dd49e2f4e17a385a459b700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f94f205c17460620000000000000000000000000000000000000000000000000000000000000000000000000ffffffff000702000000010000000000000000000000000000000000000000000000000000000000000000ffffffff6c580047304402203c9721b3dfe248ba22dbd817d3310233880ce16a44663fcf643782a7cb70b48702205e40ce6aa55439f4df780e0ac2aceea200dcb42613d8e0d96ac6e41ac5dd8c08012103fd776a5ed7b9556b9288afcfe9e97165d61857f210e8fced152f7f4fc4be0389fffffffffd05010010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e800000019";
    std::string str2 = "76a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac406868dbea0000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0000000000000000266a24aa21a9edd81e5fe7e143c954e1262b36e87dbc95ab75d3e6329dde611ffd763cfa258224000000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f45286a0000006a473044022014ff3e7c079cd5a99dfa2a7293bb529db0e84b96127ac53f6f7a719310ec258d02203468a9696b8422b947c71b9e75767487bdf4b77ef7a2584b5c1a7d7920a79501012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0220e9a9cce80000001976a914c76ef9c3c2b5b91ea0b5c1e56142f8d3363d4b6988ac00e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac070000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f4528590000006a47304402200adcd3e60872f407d5e502ca47016a2a14670bf8591485aa63257ae78c3d96d602204a830654e89785a1b003f57edfcba4b8c9630f697546279fec374a4c94a00cd2012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0200e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac20e9a9cce80000001976a91469a9ed5a2b7816439e81f5276c8fa31a5f5a17ba88ac070000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f4528240000006b483045022100b6d34ad0dd99edb2ff423df2b39fb8b7d8bb24cacb9a0ce9db43b1847ab6a0bb0220485540de7f90783ad11eca498f07640199c5a98b229571158a31b001a8437e73012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0200e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac20e9a9cce80000001976a9143d7831d6b59e5a7dba3a65b51154a3e2e4a866a088ac070000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f4528980000006b483045022100eec9b36cd4f5f9cf9354fa0802189bfd599524bc98478bef86f02e18194479cf0220090ac2f839fb2d889f2940b81a5574306a685c6df755f59298294918547edc04012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0200e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac20e9a9cce80000001976a914f405bfd6cd37be47289f1f9ca2e46b29be00af9588ac07000000020000000188d6cc289c0b578c075b29d8dcf0dd663618b66f5d9dc790d4e3b5afb26e6af7a60000006a47304402205f3fa38ff5d610c68ff5c957b6f5b048aae10edcd522b8e4127bfae835408761022071d359cfc293121d8a6ad112c74f895521b1654af9a4f25d133e693de5977c1b01210231f8f403c7a634ac42d6282903edc51cf6ccc32d34e9201c2b9e489c88b495fcfeffffff0220e9a9cce80000001976a9144d6643521444b1efb13cc8b07be9740f45f53d6488ac00e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac07000000020000000188d6cc289c0b578c075b29d8dcf0dd663618b66f5d9dc790d4e3b5afb26e6af7930000006b483045022100ae538d0225ccd95b5eb616deffdde10b4b9ad495075e796775c0d9272cd00bb4022021c804aa60ea1c45d2cab46cf55851e124ef2b218091509f547e63a46577fb7a01210231f8f403c7a634ac42d6282903edc51cf6ccc32d34e9201c2b9e489c88b495fcfeffffff0220e9a9cce80000001976a91496fdd3e3dd5643663dc65be9d4bcdb263002b85288ac00e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac070000000301000400020000";
    std::string strBlock = str1 + str2;
    MCDataStream stream(ParseHex(strBlock.c_str()), SER_NETWORK, PROTOCOL_VERSION);
    stream >> block;

    MCBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_P2PUBKEY_ONLY);
    // Match the generation pubkey
    filter.insert(ParseHex("03fd776a5ed7b9556b9288afcfe9e97165d61857f210e8fced152f7f4fc4be0389"));
    // ...and the output address of the 4th transaction
    filter.insert(ParseHex("9ea9474af84fcc6fe52a25a3d6288a479d75996e"));//inside script output?

    MCMerkleBlock merkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    // We should match the generation outpoint : Magnachain coin base output script default is P2PH
    BOOST_CHECK(!filter.contains(MCOutPoint(uint256S("0xe53e73cf99dec385737b4005bfa42ed2d8b33dd3c9c2cbb2fa9dcebe06d930c7"), 0)));
    // ... but not the 4th transaction's output (its not pay-2-pubkey)
    BOOST_CHECK(!filter.contains(MCOutPoint(uint256S("0x1a79bd3cfbdb27de6ee2bb42109e552fc53c69278b3484e801fb32a71ac9d562"), 0)));
}

BOOST_AUTO_TEST_CASE(merkle_block_4_test_update_none)
{
    // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6dea4)
    // With 7 txes
    MCBlock block;
    std::string str1 = "0000002040c8871a93779e099932c2dba1f6e75320159699a376b87472d86ab37a3324657564905c0104943684ccd7dc0c79de84d8fc4efd791dd49e2f4e17a385a459b700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f94f205c17460620000000000000000000000000000000000000000000000000000000000000000000000000ffffffff000702000000010000000000000000000000000000000000000000000000000000000000000000ffffffff6c580047304402203c9721b3dfe248ba22dbd817d3310233880ce16a44663fcf643782a7cb70b48702205e40ce6aa55439f4df780e0ac2aceea200dcb42613d8e0d96ac6e41ac5dd8c08012103fd776a5ed7b9556b9288afcfe9e97165d61857f210e8fced152f7f4fc4be0389fffffffffd05010010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e800000019";
    std::string str2 = "76a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0010a5d4e80000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac406868dbea0000001976a914c5244c2bb58d2849053233820b327cbbd463df6b88ac0000000000000000266a24aa21a9edd81e5fe7e143c954e1262b36e87dbc95ab75d3e6329dde611ffd763cfa258224000000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f45286a0000006a473044022014ff3e7c079cd5a99dfa2a7293bb529db0e84b96127ac53f6f7a719310ec258d02203468a9696b8422b947c71b9e75767487bdf4b77ef7a2584b5c1a7d7920a79501012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0220e9a9cce80000001976a914c76ef9c3c2b5b91ea0b5c1e56142f8d3363d4b6988ac00e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac070000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f4528590000006a47304402200adcd3e60872f407d5e502ca47016a2a14670bf8591485aa63257ae78c3d96d602204a830654e89785a1b003f57edfcba4b8c9630f697546279fec374a4c94a00cd2012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0200e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac20e9a9cce80000001976a91469a9ed5a2b7816439e81f5276c8fa31a5f5a17ba88ac070000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f4528240000006b483045022100b6d34ad0dd99edb2ff423df2b39fb8b7d8bb24cacb9a0ce9db43b1847ab6a0bb0220485540de7f90783ad11eca498f07640199c5a98b229571158a31b001a8437e73012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0200e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac20e9a9cce80000001976a9143d7831d6b59e5a7dba3a65b51154a3e2e4a866a088ac070000000200000001983f392a68bf061e4a893b2cc10a7dbca27c6ebd98624ccd09854b4ef64f4528980000006b483045022100eec9b36cd4f5f9cf9354fa0802189bfd599524bc98478bef86f02e18194479cf0220090ac2f839fb2d889f2940b81a5574306a685c6df755f59298294918547edc04012103d9ea5a4bc479589fde85f48237dc7e83b864787bfc5b16af6bb7d896f9b8564efeffffff0200e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac20e9a9cce80000001976a914f405bfd6cd37be47289f1f9ca2e46b29be00af9588ac07000000020000000188d6cc289c0b578c075b29d8dcf0dd663618b66f5d9dc790d4e3b5afb26e6af7a60000006a47304402205f3fa38ff5d610c68ff5c957b6f5b048aae10edcd522b8e4127bfae835408761022071d359cfc293121d8a6ad112c74f895521b1654af9a4f25d133e693de5977c1b01210231f8f403c7a634ac42d6282903edc51cf6ccc32d34e9201c2b9e489c88b495fcfeffffff0220e9a9cce80000001976a9144d6643521444b1efb13cc8b07be9740f45f53d6488ac00e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac07000000020000000188d6cc289c0b578c075b29d8dcf0dd663618b66f5d9dc790d4e3b5afb26e6af7930000006b483045022100ae538d0225ccd95b5eb616deffdde10b4b9ad495075e796775c0d9272cd00bb4022021c804aa60ea1c45d2cab46cf55851e124ef2b218091509f547e63a46577fb7a01210231f8f403c7a634ac42d6282903edc51cf6ccc32d34e9201c2b9e489c88b495fcfeffffff0220e9a9cce80000001976a91496fdd3e3dd5643663dc65be9d4bcdb263002b85288ac00e1f505000000001976a9149ea9474af84fcc6fe52a25a3d6288a479d75996e88ac070000000301000400020000";
    std::string strBlock = str1 + str2;
    MCDataStream stream(ParseHex(strBlock.c_str()), SER_NETWORK, PROTOCOL_VERSION);
    stream >> block;

    MCBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE);
    // Match the generation pubkey
    filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2c01ec0f0dd5b2e86e7168cefe0d81113c3807420ce13ad1357231a2252247d97a46a91"));
    // ...and the output address of the 4th transaction
    filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21"));

    MCMerkleBlock merkleBlock(block, filter);
    BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());

    // We shouldn't match any outpoints (UPDATE_NONE)
    BOOST_CHECK(!filter.contains(MCOutPoint(uint256S("e53e73cf99dec385737b4005bfa42ed2d8b33dd3c9c2cbb2fa9dcebe06d930c7"), 0)));
    BOOST_CHECK(!filter.contains(MCOutPoint(uint256S("1a79bd3cfbdb27de6ee2bb42109e552fc53c69278b3484e801fb32a71ac9d562"), 0)));
}

static std::vector<unsigned char> RandomData()
{
    uint256 r = InsecureRand256();
    return std::vector<unsigned char>(r.begin(), r.end());
}

BOOST_AUTO_TEST_CASE(rolling_bloom)
{
    // last-100-entry, 1% false positive:
    MCRollingBloomFilter rb1(100, 0.01);

    // Overfill:
    static const int DATASIZE=399;
    std::vector<unsigned char> data[DATASIZE];
    for (int i = 0; i < DATASIZE; i++) {
        data[i] = RandomData();
        rb1.insert(data[i]);
    }
    // Last 100 guaranteed to be remembered:
    for (int i = 299; i < DATASIZE; i++) {
        BOOST_CHECK(rb1.contains(data[i]));
    }

    // false positive rate is 1%, so we should get about 100 hits if
    // testing 10,000 random keys. We get worst-case false positive
    // behavior when the filter is as full as possible, which is
    // when we've inserted one minus an integer multiple of nElement*2.
    unsigned int nHits = 0;
    for (int i = 0; i < 10000; i++) {
        if (rb1.contains(RandomData()))
            ++nHits;
    }
    // Run test_magnachain with --log_level=message to see BOOST_TEST_MESSAGEs:
    BOOST_TEST_MESSAGE("RollingBloomFilter got " << nHits << " false positives (~100 expected)");

    // Insanely unlikely to get a fp count outside this range:
    BOOST_CHECK(nHits > 25);
    BOOST_CHECK(nHits < 175);

    BOOST_CHECK(rb1.contains(data[DATASIZE-1]));
    rb1.reset();
    BOOST_CHECK(!rb1.contains(data[DATASIZE-1]));

    // Now roll through data, make sure last 100 entries
    // are always remembered:
    for (int i = 0; i < DATASIZE; i++) {
        if (i >= 100)
            BOOST_CHECK(rb1.contains(data[i-100]));
        rb1.insert(data[i]);
        BOOST_CHECK(rb1.contains(data[i]));
    }

    // Insert 999 more random entries:
    for (int i = 0; i < 999; i++) {
        std::vector<unsigned char> d = RandomData();
        rb1.insert(d);
        BOOST_CHECK(rb1.contains(d));
    }
    // Sanity check to make sure the filter isn't just filling up:
    nHits = 0;
    for (int i = 0; i < DATASIZE; i++) {
        if (rb1.contains(data[i]))
            ++nHits;
    }
    // Expect about 5 false positives, more than 100 means
    // something is definitely broken.
    BOOST_TEST_MESSAGE("RollingBloomFilter got " << nHits << " false positives (~5 expected)");
    BOOST_CHECK(nHits < 100);

    // last-1000-entry, 0.01% false positive:
    MCRollingBloomFilter rb2(1000, 0.001);
    for (int i = 0; i < DATASIZE; i++) {
        rb2.insert(data[i]);
    }
    // ... room for all of them:
    for (int i = 0; i < DATASIZE; i++) {
        BOOST_CHECK(rb2.contains(data[i]));
    }
}

BOOST_AUTO_TEST_SUITE_END()
